package com.hcc.repository.gen.config;

import com.hcc.repository.core.constants.StrPool;
import com.hcc.repository.core.utils.StrUtils;
import lombok.Data;

/**
 * PackageConfig
 *
 * @author hushengjun
 * @date 2023/9/16
 */
@Data
public class PackageConfig {

    private String srcPath;
    private String basePackage = "";
    private String entityPackage = "entity";
    private String mapperPackage = "mapper";
    private String repositoryPackage = "repository";
    private String repositoryImplPackage = "repository.impl";
    private String servicePackage = "service";
    private String serviceImplPackage = "service.impl";
    private String controllerPackage = "controller";

    public String getSrcPath() {
        if (StrUtils.isEmpty(srcPath)) {
            return System.getProperty("user.dir") + "/src/main/java";
        }

        return srcPath;
    }

    private String getPackage(String packagePath) {
        if (StrUtils.isNotEmpty(basePackage)) {
            if (StrUtils.isEmpty(packagePath)) {
                return basePackage;
            }
            return basePackage + StrPool.POINT + packagePath;
        }
        return packagePath;
    }

    public String getEntityPackage() {
        return this.getPackage(entityPackage);
    }

    public String getMapperPackage() {
        return this.getPackage(mapperPackage);
    }

    public String getRepositoryPackage() {
        return this.getPackage(repositoryPackage);
    }

    public String getRepositoryImplPackage() {
        return this.getPackage(repositoryImplPackage);
    }

    public String getServicePackage() {
        return this.getPackage(servicePackage);
    }

    public String getServiceImplPackage() {
        return this.getPackage(serviceImplPackage);
    }

    public String getControllerPackage() {
        return this.getPackage(controllerPackage);
    }

}
